package com.martin.fastframe.ui.like.follow

import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.view.View
import com.martin.fastframe.R

/**
 * @desc：直播点赞跟随数据
 */
class LiveLikeFollowData : ILikeFollowData {

    private val iconList = arrayListOf<Any>(
        R.drawable.img_like_follow_1,
        R.drawable.img_like_follow_2,
        R.drawable.img_like_follow_3,
        R.drawable.img_like_follow_4,
        R.drawable.img_like_follow_5,
        R.drawable.img_like_follow_6,
        R.drawable.img_like_follow_7,
    )

    override fun getIconList() = iconList

    override fun getIconSize() = 100

    override fun getRotationRange() = 0..0

    override fun getYOffset() = -20

    override fun getAnimatorSet(view: View): AnimatorSet {
        val set = AnimatorSet()

        //放大
        set.playSequentially(
            AnimatorSet().apply {
                // 同时播放
                playTogether(
                    ObjectAnimator.ofFloat(view, "scaleX", 1f, 1.1f).apply {
                        duration = 50
                    },
                    ObjectAnimator.ofFloat(view, "scaleY", 1f, 1.1f).apply {
                        duration = 50
                    },
                    ObjectAnimator.ofFloat(view, "rotation", -20f, -6f).apply {
                        duration = 50
                    }
                )
            },
            //缩小
            AnimatorSet().apply {
                playTogether(
                    ObjectAnimator.ofFloat(view, "scaleX", 1.1f, 1f).apply {
                        duration = 200
                    },
                    ObjectAnimator.ofFloat(view, "scaleY", 1.1f, 1f).apply {
                        duration = 200
                    },
                    ObjectAnimator.ofFloat(view, "rotation", -6f, 4f, 0f).apply {
                        duration = 200
                    }
                )
            },
            ValueAnimator.ofInt(0, 100).apply {
                duration = 200
            },
            //缩放/透明并位移
            AnimatorSet().apply {
                playTogether(
                    ObjectAnimator.ofFloat(view, "scaleX", 1f, 1.8f).apply {
                        duration = 500
                    },
                    ObjectAnimator.ofFloat(view, "scaleY", 1f, 1.8f).apply {
                        duration = 500
                    },
                    ObjectAnimator.ofFloat(view, "alpha", 1f, 0f).apply {
                        duration = 500
                    }
                )
            })

        return set
    }
}